package com.example.yogurtsystem.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.yogurtsystem.dto.StatisticsDTO;
import com.example.yogurtsystem.entity.UserRecord;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface UserRecordMapper extends BaseMapper<UserRecord> {

    IPage<UserRecord> selectPageByCondition(IPage<UserRecord> page, @Param(Constants.WRAPPER) QueryWrapper<UserRecord> queryWrapper);

    /**
     * 查询上次记录
     * @param page
     * @param name 名称
     * @return
     */
    IPage<UserRecord> lastRecord(IPage<UserRecord> page, @Param("name") String name);

    BigDecimal getSpentBudget(String yearAndQuarter);

    /**
     * 获取当天的点餐价格
     * @param day
     * @return
     */
    BigDecimal countPriceByDay(String day);

    /**
     * 获取当天的点餐人数
     * @param day
     * @return
     */
    Integer countUserByDay(String day);

    /**
     * 统计饮品
     * @param date 日期
     * @return
     */
    List<StatisticsDTO> selectStatistics(String date);

}